﻿// Bing Maps ASP.NEt Control is a community project available under the Microsoft Public License (Ms-PL)
// Code is provided as is and with no warrenty – Use at your own risk
// View the project and the latest code at http://BingMapsASP.codeplex.com

using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI;
using Microsoft.Live.ServerControls.VE.Constants;

[assembly: WebResource("Microsoft.Live.ServerControls.VE.Extenders.ContinuousPan.js", "text/javascript")]
[assembly: WebResource("Microsoft.Live.ServerControls.VE.Extenders.ContinuousPan.debug.js", "text/javascript")]

namespace Microsoft.Live.ServerControls.VE.Extenders
{
    [ToolboxData(@"<{0}:ContinuousPan ID=""ContinuousPanExtender1"" runat=""server"" MapControlID="""" TargetControlID="""" ></{0}:ContinuousPan>")]
    public sealed class ContinuousPan : ToggleExtenderBase
    {

        #region Properties

        /// <summary>
        /// The speed, as a percentage of the fastest speed, to move the map in the x direction. Positive numbers move the map to the right, while negative numbers move the map to the left
        /// </summary>
        [Browsable(true)]
        [Category("Behaviour")]
        [DefaultValue("1")]
        [Description("The speed, as a percentage of the fastest speed, to move the map in the x direction. Positive numbers move the map to the right, while negative numbers move the map to the left")]
        public int X
        {
            get { return (int)(ViewState[ContinuousPanExtenderControlProperty.X] ?? 1); }
            set
            {
                ViewState[ContinuousPanExtenderControlProperty.X] = value;
            }
        }

        /// <summary>
        /// The speed, as a percentage of the fastest speed, to move the map in the y direction. Positive numbers move the map down, while negative numbers move the map up
        /// </summary>
        [Browsable(true)]
        [Category("Behaviour")]
        [DefaultValue("1")]
        [Description("The speed, as a percentage of the fastest speed, to move the map in the y direction. Positive numbers move the map down, while negative numbers move the map up")]
        public int Y
        {
            get { return (int)(ViewState[ContinuousPanExtenderControlProperty.Y] ?? 1); }
            set
            {
                ViewState[ContinuousPanExtenderControlProperty.Y] = value;
            }
        }

        #endregion

        #region ExtenderControl Members

        protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors(Control targetControl)
        {
            ScriptBehaviorDescriptor descriptor = new ScriptBehaviorDescriptor("Microsoft.Live.ClientControls.VE.Extenders.ContinuousPan", targetControl.ClientID);
            descriptor.AddProperty(ContinuousPanExtenderControlProperty.X, X);
            descriptor.AddProperty(ContinuousPanExtenderControlProperty.Y, Y);
            descriptor.AddProperty(ExtenderControlProperty.ToggleMode, ToggleMode);
            descriptor.AddProperty(ExtenderControlProperty.MapControlID, MapControlID);
            yield return descriptor;
        }

        protected override IEnumerable<ScriptReference> GetScriptReferences()
        {
            List<ScriptReference> descriptors = new List<ScriptReference>();
            descriptors.Add(new ScriptReference("Microsoft.Live.ServerControls.VE.Extenders.ContinuousPan.js", GetType().Assembly.FullName));
            return descriptors;
        }

        #endregion
    }
}
